import { CopyInfoPanelBase } from "../../CopyInfoPanelBase";
import { GTextFormat } from "../../../../../common/GTextFormat";
import { FontUtil } from "../../../../../common/font/FontUtil";
import { ObjCreate } from "../../../common/ObjCreate";
import { Language } from "../../../../../../extend/language/Language";
import { FilterConst } from "../../../../../component/gconst/FilterConst";
import { GlobalStyle } from "../../../../../common/global/GlobalStyle";
import { GuildRobCityCopyTwoListRenderer } from "./GuildRobCityCopyTwoListRenderer";
import { DataProvider } from "../../../../../../fl/data/DataProvider";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../../events/DataEvent";
import { EventName } from "../../../../mvc/EventName";
import { SRobCityTwoJoinTeamInfo } from "../../../../../../Message/Public/SRobCityTwoJoinTeamInfo";
import { SRobCityTwoStart } from "../../../../../../Message/Public/SRobCityTwoStart";
import { ClockManager } from "../../../../manager/ClockManager";
import { SecTimerView } from "../../../common/SecTimerView";
import { GTileList } from "../../../../../../com/mui/controls/GTileList";
import { GTextFiled } from "../../../../../../com/mui/controls/GTextFiled";
type int = number;
//class GuildRobCityCopyTwoInfoPanel
    
    export  class GuildRobCityCopyTwoInfoPanel extends CopyInfoPanelBase
    {
        constructor(arg1: string="MagicTowerInfoButtonBg")
        {
            super(arg1);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            _titleSp.buttonMode = true;
            _titleSp.addEventListener(flash.events.MouseEvent.CLICK, this.onTitleClickHandler);
            var loc1=new GTextFormat(FontUtil.songtiName, 12, 16776960, true);
            this._secTimer = ObjCreate.createSecTimeView(Language.getString(60923), 10, 10, 240, 20, _bodySp, loc1);
            this._secTimer.selectable = false;
            this._secTimer.filters = [FilterConst.glowFilter];
            var loc2=new GTextFormat(FontUtil.songtiName, 12, 6350622, true);
            ObjCreate.createGTextField(Language.getString(57322) + ":", 10, 35, 200, 20, _bodySp, loc2);
            ObjCreate.createGTextField(Language.getString(60944), 10, 55, 150, 20, _bodySp, loc2);
            ObjCreate.createGTextField(Language.getString(60945), 160, 55, 45, 20, _bodySp, GlobalStyle.getTextFormatCenter(loc2));
            ObjCreate.createGTextField(Language.getString(60946), 205, 55, 45, 20, _bodySp, GlobalStyle.getTextFormatCenter(loc2));
            this._listPanel = ObjCreate.createTileList(10, 75, 250, 130, _bodySp);
            this._listPanel.rowHeight = 20;
            this._listPanel.columnWidth = 245;
            this._listPanel.verticalScrollPolicy = "off";
            this._listPanel.setStyle("cellRenderer", GuildRobCityCopyTwoListRenderer);
            this._rankLabel = ObjCreate.createGTextField("", 10, 210, 240, 20, _bodySp, new GTextFormat(null, 12, 16776960, true, null, true, null, null, flash.text.TextFormatAlign.RIGHT, null, 5));
            this._rankLabel.htmlText = "<u><a href=\'event: 0\'>" + Language.getString(60973) + "</a></u>";
            this._rankLabel.addEventListener(flash.events.TextEvent.LINK, this.onRankLabelClick);
            this._listDp = new DataProvider();
            _bg.height = 240;
            return;
        }

        /* internal  */onRankLabelClick(arg1): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.RobCity_ShowCopyTwoRankPanel));
            return;
        }

        /* internal  */onTitleClickHandler(arg1): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.RobCity_ShowCopyTwoRankPanel));
            return;
        }

        public /* override */ updateInfos(arg1): void
        {
            var loc1=arg1 as SRobCityTwoJoinTeamInfo;
            if (loc1) 
            {
                this._listDp.removeAll();
                this._listDp.addItems(loc1.robCityTwoJoinTeams);
                this._listDp.sortOn("score", Array.DESCENDING | Array.NUMERIC);
                this._listPanel.dataProvider = this._listDp;
            }
            return;
        }

        public updateLeftTime(arg1: SRobCityTwoStart, arg2: Boolean): void
        {
            if (arg1) 
            {
                if (arg2) 
                {
                    this._secTimer.setParse(Language.getString(60923));
                    this._secTimer.setLeftTime((arg1.endDt.time - ClockManager.instance.nowDate.time) / 1000);
                }
                else 
                {
                    this._secTimer.setParse(Language.getString(60922));
                    this._secTimer.setLeftTime((arg1.startDt.time - ClockManager.instance.nowDate.time) / 1000);
                }
            }
            return;
        }

        public stopCountDown(): void
        {
            if (this._secTimer) 
            {
                this._secTimer.stop();
            }
            return;
        }

        public clean(): void
        {
            this._secTimer.dispose(false);
            return;
        }

        /* internal */ /* var */_totalTime: int=1800000;

        /* internal */ /* var */_secTimer: SecTimerView;

        /* internal */ /* var */_listPanel: GTileList;

        /* internal */ /* var */_listDp: DataProvider;

        /* internal */ /* var */_rankLabel: GTextFiled;
    }
